//
//  UnderMineViewController.swift
//  AnShiPai
//
//  Created by 马瑜 on 2017/7/7.
//  Copyright © 2017年 马瑜. All rights reserved.
//  接单中我的数据

import UIKit
import Foundation
import RxSwift
import RxDataSources
import RxCocoa


class UnderMineViewController: BaseViewController {

    
    @IBOutlet weak var tableView: UITableView!
    
    let dataSource = ["我的大数据", "甩单账户", "我的评价", "甩单记录"]
    let dataSourceImage = ["T-M-BigData", "T-M-Account", "T-M-Record", "T-M-Evaluate"]
    
    
    override func viewWillAppear(_ animated: Bool) {
        super.viewWillAppear(animated)
        setBackBarBotton()
    }
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        
    }
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
}


extension UnderMineViewController: UITableViewDelegate, UITableViewDataSource {

    
    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return dataSource.count
    }

    
    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell = tableView.dequeueReusableCell(withIdentifier: "UnderMineTableViewCell", for: indexPath) as! UnderMineTableViewCell
        cell.conentLab.text = dataSource[indexPath.row]
        cell.leftImageView.image = UIImage(named: dataSourceImage[indexPath.row])
        
        return cell
        
    }
    
    
    
}


extension UnderMineViewController: UIScrollViewDelegate {
    
    func scrollViewDidScroll(_ scrollView: UIScrollView) {
        
        if SCREENH >= ScrollViewBaseHeight {
            scrollView.contentOffset.y = 0
        } else {
            if scrollView.contentOffset.y < 0 {
                scrollView.contentOffset.y = 0
            }
        }
        
        let contentOffsetY = scrollView.contentOffset.y
        let showNavBarOffsetY = 74 - topLayoutGuide.length
        
        
        //navigationBar alpha
        if contentOffsetY > showNavBarOffsetY  {
            var navAlpha = (contentOffsetY - (showNavBarOffsetY)) / 40.0
            if navAlpha > 1 {
                navAlpha = 1
            }
            navBarBgAlpha = navAlpha
            //            if navAlpha > 0.8 {
            //                navBarTintColor = UIColor.globalColor
            //            }else{
            //                navBarTintColor = UIColor.white
            //            }
        }else{
            navBarBgAlpha = 0
            navBarTintColor = UIColor.white
        }
        //        setNeedsStatusBarAppearanceUpdate()
        
    }
    
    
}




